//
// Created by hsj on 2024-1-12.
// fdopen： 文件描述符转FILE指针标准IO

#include <stdio.h>
#include <fcntl.h>
int main(void) {
    FILE *fp;
    int fd = open("syscpy_to_stdcpy.txt", O_WRONLY | O_CREAT | O_TRUNC);
    if (fd == -1) {
        fputs("file open error", stdout);
        return -1;
    }
    fp = fdopen(fd, "w");//文件描述符转FILE指针
    fputs("Network C programming \n", fp);
    fclose(fp);
    return 0;
}